package com.jlastu.androiduidemo.views;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.jlastu.androiduidemo.R;
import com.jlastu.androiduidemo.widget.HeaderView;

public class SettingsActivity extends AppCompatActivity {

   private HeaderView mheaderview;
   private Button ma1;
   private Button ma3;
   private Switch ma5;
   private Button ma7;
   private Button ma6;
   private Button ma8;
   private Button mb4;

   @Override
   protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_settings);
      mheaderview=findViewById(R.id.header_view);
      mheaderview.setTitle("设置");

      mb4=findViewById(R.id.b4);
      mb4.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            onBackPressed();
         }
      });

      ma1 = findViewById(R.id.a1);
      ma1.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            Intent intent=new Intent(SettingsActivity.this,UpdatePassword.class);
            startActivity(intent);
         }
      });

      ma3 = findViewById(R.id.a3);
      ma3.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            Toast.makeText(SettingsActivity.this, "发布成功", Toast.LENGTH_SHORT).show();
         }
      });

      ma5 = findViewById(R.id.a5);
      ma5.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
         @Override
         public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (ma5.isChecked()){
               Toast.makeText(SettingsActivity.this,"已开启管理员模式",Toast.LENGTH_LONG).show();
               ma6.setVisibility(View.VISIBLE);
               ma7.setVisibility(View.VISIBLE);

            }else {
               Toast.makeText(SettingsActivity.this,"已关闭管理员模式",Toast.LENGTH_LONG).show();
               ma6.setVisibility(View.GONE);
               ma7.setVisibility(View.GONE);
            }

         }
      });
      ma6=findViewById(R.id.a6);
      ma6.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            Intent intent=new Intent(SettingsActivity.this,Add_course.class);
            startActivity(intent);
         }
      });

      ma7=findViewById(R.id.a7);
      ma7.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            Intent intent=new Intent(SettingsActivity.this,Add_student.class);
            startActivity(intent);
         }
      });

      ma8=findViewById(R.id.a8);
      ma8.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            Intent intent=new Intent(SettingsActivity.this,Login.class);
            startActivity(intent);
         }
      });

   }

}
